const puppeteer = require('puppeteer-core')
//find_chrome模块来源于GoogleChromeLabs的Carlo
const findChrome = require('../node_modules/carlo/lib/find_chrome')
const proxyChain = require('proxy-chain')
// 获取浏览器实例
async function getBrowser() {
  // change username & password
  const oldProxyUrl = '--proxy-server=http://113.121.240.67:808'
  // const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);
  let findChromePath = await findChrome({})
  let executablePath = findChromePath.executablePath
  const browser = await puppeteer.launch({
    executablePath,
    headless: false,
    args: ['--no-sandbox', '--disable-setuid-sandbox', `--proxy-server=${oldProxyUrl}`],
    slowMo: 50,
  })
  return browser
}
module.exports = getBrowser
